#pragma once
#include <CEGUIScriptModule.h>

namespace ScriptBackend
{
	using namespace CEGUI;
	class LuabindScriptModule:
		public ScriptModule
	{
	public:
		typedef void(*Callback_OnDestroyBindings)();
	private:
		lua_State* luaState;
		Callback_OnDestroyBindings onDestroyBindings;
	public:		
		LuabindScriptModule(lua_State* l,Callback_OnDestroyBindings onDestroy = 0);
		~LuabindScriptModule(void);
	public:
		void executeScriptFile(const String& filename, const String& resourceGroup = "");

		int	executeScriptGlobal(const String& function_name);

		bool executeScriptedEventHandler(const String& handler_name, const EventArgs& e);

		void executeString(const String& str);

		void createBindings(void);

		void destroyBindings(void);

		Event::Connection subscribeEvent(EventSet* target, const String& name, const String& subscriber_name);

		Event::Connection subscribeEvent(EventSet* target, const String& name, Event::Group group, const String& subscriber_name);
	};
}
